//
//  ABService.h
//  TTProject
//
//  Created by 张志恒 on 16/9/19.
//  Copyright © 2016年 Dail. All rights reserved.
//

#import <Foundation/Foundation.h>

// 通用请求参数
@protocol ABCommonParamsProtocal <NSObject>

- (NSDictionary *)commonParamsDictionary;

@end

// 参数签名机制，暂未实现
@protocol ABSignatureProtocal <NSObject>

- (NSString *)signGetWithAllParams:(NSDictionary *)allParams
                        methodName:(NSString *)methodName
                        apiVersion:(NSString *)apiVersion
                        privateKey:(NSString *)privateKey
                         publicKey:(NSString *)publicKey;

- (NSString *)signPostWithAllParams:(NSDictionary *)allParams
                         methodName:(NSString *)methodName
                         apiVersion:(NSString *)apiVersion
                         privateKey:(NSString *)privateKey
                          publicKey:(NSString *)publicKey;

@end

// 所有ABService的派生类都要符合这个protocal
@protocol ABServiceProtocal <NSObject>

@property (nonatomic, readonly) BOOL isOnline;

@property (nonatomic, readonly) NSString *offlineApiBaseUrl;
@property (nonatomic, readonly) NSString *onlineApiBaseUrl;

@property (nonatomic, readonly) NSString *offlineApiVersion;
@property (nonatomic, readonly) NSString *onlineApiVersion;

@property (nonatomic, readonly) NSString *onlinePublicKey;
@property (nonatomic, readonly) NSString *offlinePublicKey;

@property (nonatomic, readonly) NSString *onlinePrivateKey;
@property (nonatomic, readonly) NSString *offlinePrivateKey;

@end

@interface ABService : NSObject

@property (nonatomic, copy, readonly) NSString *publicKey;
@property (nonatomic, copy, readonly) NSString *privateKey;
@property (nonatomic, copy, readonly) NSString *apiBaseUrl;
@property (nonatomic, copy, readonly) NSString *apiVersion;

@property (nonatomic, weak) id<ABCommonParamsProtocal> commParamsGenerator;
@property (nonatomic, weak) id<ABSignatureProtocal> signGenerator;

@property (nonatomic, weak) id<ABServiceProtocal> child;

@end
